<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath%>">
		<title>分店密码修改</title>
		<%@include file="../collect/meta.jsp"%>
		<script src="${ctx}/js/md5.js"></script>
		<script type="text/javascript" src="${ctx}/js/returnTop.js"></script>
		<style type="text/css">
			.input {
				width: 180px;
				height: 25px;
				font-size: 14px
			}
			
			.tbinput {
				width: 180px;
				height: 25px;
				font-size: 14px;
				background-color: #FFFFCC
			}
			
			.error {
				color: red
			}
			
			.success {
				color: green
			}
		</style>
		<link rel="stylesheet" href="css/radius.css" type="text/css"></link>
	</head>
	<body lang="zh-cn">
		<div class="wrapper">
			<c:import url="/muser/musertop.jsp"></c:import>
			<div class="main-container" id="main-container">
				<div class="main-container-inner">
					<c:import url="/muser/muserleft.jsp"></c:import>
					<div class="main-content">
						<div class="breadcrumbs" id="breadcrumbs">
							<ul class="breadcrumb">
								<li>
									<i class="icon-home home-icon"></i>密码管理
								</li>
								<li>
									分店账号密码管理
								</li>
								<li>
									密码修改
								</li>
							</ul>
							<!-- .breadcrumb -->
						</div>
						<div class="page-content">
							<div class="row">
								<div class="col-xs-12">
									<!-- PAGE CONTENT BEGINS -->
									<form action="muser!updateUser" name="updateuser" method="post">
										<div align="center">
											<table>
												<caption>
												<label style="font-weight: bold;">	登陆账号：${user.loginName }</label>
												</caption>
												<tr>
													<td>
														<div align="right">
															请输入旧密码：
														</div>
													</td>
													<td>
														<input type="password" name="passwordOld"
															id="passwordOld" />
													</td>
												</tr>
												<tr>
													<td>
														<div align="right">
															新密码：
														</div>
													</td>
													<td>
														<input type="password" name="userpassword"
															id="userPassword1" />
													</td>
												</tr>
												<tr>
													<td>
														<div align="right">
															请再次输入：
														</div>
													</td>
													<td>

														<input type="password" id="userPassword2" />
														<label id="p2label"></label>
													</td>
												</tr>
												<tr>

													<td>
														<div align="right">
															<input type="hidden" name="user.id" value="${user.id }"
																id="userId" />
														</div>
													</td>
													<td colspan="2">
														<input type="button" class="btn btn-primary radius" id="pButton"
															value="修改">
														<!--  <a class="btn btn-primary" href="muser!selectUser">返回</a>-->
													</td>
													<td>
														<input type="hidden" name="user.createTime"
															value="${user.createTime }" />
													</td>
												</tr>
											</table>
										</div>
									</form>
									<!-- PAGE CONTENT ENDS -->
								</div>
								<!-- /.col -->
							</div>
							<!-- /.row -->
						</div>
						<!-- /.page-content -->
					</div>
					<!-- /.main-content -->
				</div>
				<!-- /.main-container-inner -->
				<a href="#" id="btn-scroll-up"
					class="btn-scroll-up btn btn-sm btn-inverse"
					style="position: fixed; bottom: 0;"> <i
					class="icon-double-angle-up icon-only bigger-110"></i> </a>
			</div>
			<!-- /.main-container -->
			<div class="push"></div>
		</div>
		<c:import url="/collect/down.jsp"></c:import>

		<script type="text/javascript">
	$(function() {
		$('#accountPassword2').blur(function() {
			var p2 = $('#userPassword2').val();
			var p1 = $('#userPassword1').val();
			if (p1 != p2) {
				alert('两次密码输入不一致');
			}
		});

	});

	$('#pButton').click(function() {
		var p2 = $('#userPassword2').val();
		var p1 = $('#userPassword1').val();
		if (p1.length != 0) {
			if (p1 != p2) {
				alert('两次密码输入不一致');
			} else {

				var password = $('#userPassword1').val();
				var userId = $('#userId').val();
				var passwordOld=$('#passwordOld').val();
				$.ajax( {
					async : false,
					url : "muser!updatePasswordById",
					type : "post",
					data : {
						"userpassword" : faultylabs.MD5(password),
						"userId" : userId,
						"passwordOld":faultylabs.MD5(passwordOld)
					},
					datatype : "json",
					success : function(data) {
						var d = eval("(" + data + ")");
						alert(d.temp);
						

					},
					error : function(request) {
						alert("Connection error");
					}
				});
			}
		} else {
			alert('密码不能为空');
		}
	});
</script>
	</body>
</html>